#define _CRT_SECURE_NO_WARNINGS 1

#include"RBTree.h"

void test1()
{
	RBTree<int,int> Tree;
	int a[] = { 4, 2, 6, 1, 3, 5, 15, 7, 16, 14, 16, 3, 7, 11, 9, 26, 18, 14, 15 };
	for (auto e : a)
	{
		Tree.Insert(make_pair(e,e));
	}

	cout << "4 " << Tree.Find(4) << endl;
	cout << "1000 " << Tree.Find(1000) << endl;

	cout << Tree.Height() << endl;
	cout << Tree.IsBanlance() << endl;

	Tree.Inorder();
}

void test2()
{
	RBTree<int, int> Tree;
	int cnt = 100000000;
	while (cnt--)
	{
		int num = rand() % 100000000;
		Tree.Insert(make_pair(num, num));
	}
	cout << Tree.Height() << endl;
	cout << Tree.IsBanlance() << endl;
}

void test3()
{
	RBTree<int, int> Tree;
	int a[] = { 4, 2, 6, 1, 3, 5, 15, 7, 16, 14,  11, 9, 26, 18, 14, 15 };
	for (auto e : a)
	{
		Tree.Insert(make_pair(e, e));
	}
	Tree.Inorder();

	Tree.Erase(4);
	cout << Tree.IsBanlance() << endl;

	Tree.Erase(2);
	cout << Tree.IsBanlance() << endl;

	Tree.Erase(6);
	//cout << Tree.IsBanlance() << endl;

	Tree.Erase(1);
	//cout << Tree.IsBanlance() << endl;

	Tree.Erase(3);
	//cout << Tree.IsBanlance() << endl;

	Tree.Erase(5);
	//cout << Tree.IsBanlance() << endl;

	Tree.Erase(15);
	//cout << Tree.IsBanlance() << endl;

	Tree.Erase(7);
	//cout << Tree.IsBanlance() << endl;


	Tree.Erase(16);
	//cout << Tree.IsBanlance() << endl;


	Tree.Erase(14);
	//cout << Tree.IsBanlance() << endl;

	Tree.Erase(11);
	//cout << Tree.IsBanlance() << endl;

	Tree.Erase(9);
	//cout << Tree.IsBalance() << endl;

	Tree.Erase(26);
	//cout << Tree.IsBanlance() << endl;

	Tree.Erase(18);
	//cout << Tree.IsBanlance() << endl;

	Tree.Erase(14);
	Tree.Inorder();
	cout << Tree.IsBanlance() << endl;

	Tree.Erase(15);
	cout << Tree.IsBanlance() << endl;
}

int main()
{
	//test1();
	//test2();
	test3();
	return 0;
}

